package com.rattsoftware.client.model;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.rattsoftware.server.admin.model.Course;

public class CourseSummary extends BaseModel {

	/**
	 * Base model representation of a given course.
	 */
	private static final long serialVersionUID = 1L;

	private Course course;

	public CourseSummary(Course course) {
		this.setCourse(course); 
		setId (Integer.parseInt(course.getId()));
        setData("courseName", course.getName());
        setData("courseDescription", course.getDescription());
        setData("noOfCourseUnits", course.getNumOfCourseunits());
        setData("courseType", course.getType());
        setData("shortName", course.getShortname());
        setData("departmentName", course.getDepartment().getName());
        setData("duration", course.getDuration());
	}
	
	public String getId() {
		return get("courseId");
	}
	
	public void setId(Integer id) {
		set("courseId", id);
	}

    public void setStatus(String status) {
        set("status", status);
    }
    
    public <X> X setData(String name, X value) {
        return set(name, value);
    }

	public void setCourse(Course course) {
		this.course = course;
	}

	public Course getCourse() {
		return course;
	}
	
	public String getCourseName() {
		return get("courseName");
	}
	
	public String getCourseDescription() {
		return get("courseDescription");
	}
	
	public String getNoOfCourseUnits() {
		return get("noOfCourseUnits");
	}
	
	public String getCourseDuration() {
		return get("duration");
	}
	
	public String getNoOfSemester() {
		return get("noOfSemester");
	}
	
	public String getShortName() {
		return get("shortName");
	}
	
	public String getCourseType() {
		return get("courseType");
	}
	
	public String getDepartmentName() {
		return get("departmentName");
	}
	
	public void updateCourseSummary(Course course) {
		setId (Integer.parseInt(course.getId()));
        setData("courseName", course.getName());
        setData("courseDescription", course.getDescription());
        setData("noOfCourseUnits", course.getNumOfCourseunits());
        setData("courseType", course.getType());
        setData("shortName", course.getShortname());
        setData("departmentName", course.getDepartment().getName());
        setData("duration", course.getDuration());
	}
}
